#ifndef F_CAAvoidObstaclesC_h
#define F_CAAvoidObstaclesC_h

// ***********************************************************************

// class EDROOMTopContext

// ***********************************************************************



class EDROOMTopContext {

protected:

enum EDROOMCAAvoidObstaclesSignal { EDROOMSignalTimeout, EDROOMSignalDestroy, SConfigAO, SStart, SConfigOK, SConfigError, SObstacleDetected };


	friend class CAAvoidObstacles;

	CAAvoidObstacles &EDROOMcomponent;

	CEDROOMMessage * &Msg;

	CEDROOMMessage * &MsgBack;

	//Ports

	CEDROOMInterface & AvoidObstaclesSysCtrl;
	CEDROOMTimingInterface & Timer;

	enum edroomStateId{I, Idle, Ready};

	enum IdTrans{Init, Config, Start, CheckObstacles, CheckObstacles_ObstDetected, CheckObstacles_NoObstacle,  EDROOMMEMORIA };

	//Constantes



	//Variables

	TEDROOMBool &VObsDetected;


	//Pool



	// CONSTRUCTORES

	EDROOMTopContext (CAAvoidObstacles &act, TEDROOMBool & EDROOMpVarVObsDetected );

	EDROOMTopContext ( EDROOMTopContext &contex );

public:

	bool EDROOMSearchContextTrans(TEDROOMTransId &edroomCurrentTrans);

	void EDROOMNuevoMens () { EDROOMcomponent.EDROOMNewMsg(); }

	// Funciones Definidas por el usuario

	void	FCheckObstacles();

	void	FConfigOK();

	void	FHandleObstacles();

	void	FProgNextDetection();

};

// ***********************************************************************

// class EDROOMTopState

// ***********************************************************************



class EDROOMTopState : public EDROOMTopContext {

protected:



	EDROOMTopContext::edroomStateId edroomCurrentState;

	EDROOMTopContext::edroomStateId edroomNextState;

	//Variables

	TEDROOMBool VObsDetected;


	//Pools



public:

	// CONSTRUCTOR

	EDROOMTopState (CAAvoidObstacles &act );


	// EDROOMBehaviour**********************************************

	void EDROOMBehaviour();

	// Inicio**********************************************

	void EDROOMInicio();

	// ***********************************************************************

	// SubEstado Inicial 

	// ***********************************************************************



	TEDROOMTransId EDROOMIllegada();

	// ***********************************************************************

	// SubEstado Hoja Idle

	// ***********************************************************************



	TEDROOMTransId EDROOMIdlellegada();

	// ***********************************************************************

	// SubEstado Hoja Ready

	// ***********************************************************************



	TEDROOMTransId EDROOMReadyllegada();

};


#endif
